//////////////////////////////////////////////////////////////////////////////////
//	File Name:	BaseInterface.h
//	Author	 :	Yuri Oyoko
//	Purpose	 :	The base file from which certain objects will inherit
//////////////////////////////////////////////////////////////////////////////////

#pragma once
#include "BaseInterface.h"

#include <windows.h>
#include <d3dx9.h>

class BaseObject : public BaseInterface
{
private:
	//	Reference count
	unsigned int ReferenceCount;	

	
protected:
	

	//	graphic
	int ImageID;
	int Width;
	int Height;

	bool IsActive;

protected:
	int ObjectType;
	//	position
	D3DXVECTOR2 Position;
	//	velocity
	D3DXVECTOR2 Velocity;
public:

	enum OBJECT_TYPES {PLAYER = 0, ENEMY, BOX, PILLS, FIRST_AID, AMMO}; 

	BaseObject(void);
	virtual ~BaseObject(void);

	////////////////////////////////////////////////////
	//	Function:	Modifiers
	//
	//	Purpose:	To set the specified variable.
	////////////////////////////////////////////////////
	inline void SetPositionX(float Value)						{ Position.x = Value; }
	inline void SetPositionY(float Value)						{ Position.y = Value; }
	inline void SetPosition(D3DXVECTOR2 newPosition)			{ Position = newPosition;}
	inline void SetVelocityX(float Value)						{ Velocity.x = Value; }
	inline void SetVelocityY(float Value)						{ Velocity.x = Value; }
	inline void SetVelocity(D3DXVECTOR2 newVelocity)			{ Velocity = newVelocity;}
	inline void SetWidth(int Value)		{ Width = Value;}
	inline void SetHeight(int Value)	{ Height = Value;}
	inline void SetImageID(int Value)	{ ImageID = Value; }
	inline void SetIsActive(bool Value)	{ IsActive = Value; }

	////////////////////////////////////////////////////
	//	Function:	Accessors
	//
	//	Purpose:	To get the specified variable.
	////////////////////////////////////////////////////
	inline float GetPositionX(void)			{ return Position.x; }
	inline float GetPositionY(void)			{ return Position.y; }
	inline D3DXVECTOR2 GetPosition(void)	{ return Position;}
	inline float GetVelocityX(void)			{ return Velocity.x; }
	inline float GetVelocityY(void)			{ return Velocity.y; }
	inline D3DXVECTOR2 GetVelocity(void)	{ return Velocity;}
	inline int GetImageID(void)				{ return ImageID; }
	inline int GetWidth(void)				{ return Width; }
	inline int GetHeight(void)				{ return Height; }
	inline int GetObjectType(void)			{ return ObjectType; }
	inline bool GetIsActive(void)			{ return IsActive; }

	/////////////////////////////////////////////////////////
	//	Function:	Update
	//
	//	Purpose:	Updates the objects
	/////////////////////////////////////////////////////////
	virtual void Update(float ElapsedTime);

	/////////////////////////////////////////////////////////
	//	Function:	Render
	//
	//	Purpose:	Draws the Objects
	/////////////////////////////////////////////////////////
	virtual void Render(void);

	/////////////////////////////////////////////////////////
	//	Function:	AddRef
	//
	//	Purpose:	Counts how many objects have pointers to this one
	/////////////////////////////////////////////////////////
	void AddReference(void)
	{
		ReferenceCount++;
	}

	/////////////////////////////////////////////////////////
	//	Function:	Release
	//
	//	Purpose:	Decrements counts by 1 
	//				and delete object if count =0
	/////////////////////////////////////////////////////////
	void Release(void)
	{
		ReferenceCount--;

		if (ReferenceCount == 0)
			delete this;
	}

	/////////////////////////////////////////////////////////
	//	Function:	GetCollisionRect
	//
	//	Purpose:	Check for Collision between 2 rect
	//
	//	Return:		Returns a Rect
	/////////////////////////////////////////////////////////
	virtual RECT GetCollisionRect();


	/////////////////////////////////////////////////////////
	//	Function:	CheckCollisions
	//
	//	Purpose:	Check for Collisions
	//
	//	Return:		bool for true or false
	/////////////////////////////////////////////////////////
	virtual bool CheckCollision(BaseObject* theObject);
};